package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.ProcurementProduct;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ProcurementProductDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "采购单id")
    private Integer procurementId;

    @ApiModelProperty(value = "请购物品SPU_id")
    private Integer requisitionProductId;

    @ApiModelProperty(value = "物品Spu_id")
    private Integer productSpuId;

    @ApiModelProperty(value = "对内购买数量")
    private Double productBuyNum;

//    @ApiModelProperty(value = "对外购买数量")
//    private Double financeBuyNum;

    @ApiModelProperty(value = "仓库单位id")
    private Integer unitId;

//    @ApiModelProperty(value = "采购单位id")
//    private Integer financeUnitId;
//
//    @ApiModelProperty(value = "默认转换率")
//    private Double conversionRate;

    @ApiModelProperty(value = "单价")
    private Double price;

    @ApiModelProperty(value = "总价")
    private Double productBuyPrice;

    @ApiModelProperty(value = "实际到货数量")
    private Double actualNum;


    public ProcurementProductDTO() {}

    public ProcurementProductDTO(ProcurementProduct entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static ProcurementProductDTO convert(ProcurementProduct entity) {
        return new ProcurementProductDTO(entity);
    }

    public static List<ProcurementProductDTO> convertList(List<ProcurementProduct> list) {
        List<ProcurementProductDTO> resultList = new ArrayList<>();
        for (ProcurementProduct entity : list) {
            resultList.add(new ProcurementProductDTO(entity));
        }
        return resultList;
    }}
